/*
********************************************************************************
* Copyright (C) 2021, xiang.D <dx_65535@163.com>.
* All right reserved.
*
* File Name   : shop.cc
* Author      :
* Version     : V1.0
* Description :
* Journal     : 2021-01-08 init v1.0
* Brief       : Blog: https://blog.csdn.net/qq_38750572?spm=1001.2014.3001.5343
* Others      :
********************************************************************************
*/
#include <stdio.h>
#include "shop.h"

CShop::CShop()
{
    // 默认为普通用户
    SetConsumer(COSUMER_COMMON);
}

CShop::~CShop()
{

}

float CShop::GetRealPrice(float price)
{
    return mConsumer->GetRealPrice(price);
}

int CShop::BirthdayPresent()
{
    return mConsumer->GetBirthdayPresent();
}

void CShop::SetCurrentDiscountRate(float rate)
{
    return mConsumer->SetDiscountRate(rate);
}

float CShop::GetCurrentDiscountRate()
{
    return mConsumer->GetDiscountRate();
}

int CShop::SetConsumer(EConsumerType type)
{
    switch (type)
    {
        case COSUMER_COMMON:
            mConsumer = CCommonUser::GetInstance();
        break;

        case COSUMER_SILVER:
            mConsumer = CSilverUser::GetInstance();
        break;

        case COSUMER_GOLD:
            mConsumer = CGoldUser::GetInstance();
        break;

        default:
        break;
    }

    if (NULL == mConsumer) {
        return -1;
    }

    return 0;
}